<?php
/**
 *  获取玩家背包
 */

class GetBackpack extends APIBase {
	public $tag = "GetBackpack";
	public $isLogin = true;
	
	public function before() {
		$this->initMysql();
		$this->inithttp();
		$this->initCacheRedis();
		return true;
	}
			
	public function logic() {
	    $uid = $this->uid;
		$keys = $this->cache_redis->keys("hbackpack:{$uid}:*");
		if(count($keys)>0){
			$data = array();
			foreach($keys as $val){
				$row = $this->cache_redis->hGetAll($val);
				//根据propid获取道具详情
				$propinfo = $this->cache_redis->hMGet("prop:".$row['propid'],array('id','icon','name','desc'));
				if($propinfo['id']==1){
					$data[] = array('id'=>$propinfo['id'],'icon'=>$propinfo['icon'],'name'=>$propinfo['name'],'desc'=>$propinfo['desc'],'count'=>$row['count']);
				}
			}
			$this->returnData($data);
		}else{
			$this->returnError(301,'背包暂无道具！');
		}
	}

	public function after() {
		$this->deinitDataRedis();
		$this->deinitMysql();
	}
}

?>
